package com.yonyou.ucf.mdf.app.isvdxq.common;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;

@Component
public class DxqConfig {
    public static final String DXQ_ACCESS_TOKEN = "access_token";
    public static final String DXQ_tenantId = "tenant_id";
    public static final String DXQ_userId = "userId";
    public static final String pre_apiUrl = "/gdgy/api/isv2";
    public static final String pre_pcUrl = "/gdgy/pc/isv2";

    //获取租户所在数据中心域名
    // 【获取租户所在数据中心域名】接口请求地址域名由 api.diwork.com 调整为 apigateway.yonyoucloud.com
    public static final String datacenterDomain = "https://apigateway.yonyoucloud.com";
    public static final String datacenterUrl = "https://apigateway.yonyoucloud.com/open-auth/dataCenter/getGatewayAddress?tenantId=%s";
    //前台应用code
    public static final String applicationCode = "GDGY01";
    //应用服务code 智能货位列表
    public static final String serviceCode = "dxq_locationList";//1556234283920654344
    public static final String serviceName = "智能货位列表";

    //交易类型
    public static final String transtype_otherin = "A08001"; //基他入库
    public static final String transtype_otherout = "A10001"; //其他出库
    public static final String transtype_pandianin = "A08002"; //盘盈入库
    public static final String transtype_pandianout = "A10002"; //盘亏出库
    public static final String transtype_in = "A15001"; //普通采购
    public static final String transtype_proin = "A18001"; //产品入库
    public static final String transtype_out = "A30001"; //普通出库
    public static final String transtype_materialout = "A19001"; //材料出库

    //业务字段类型
    public static final int StatusDef = 0;
    public static final int StatusOk = 1;
    public static final int StatusFail = -1;
    public static final int TypeFail = 6;
    public static final int TypeOutIn = 7; //出人库单
    public static final int TypeOut = 2; //发货单出库
    public static final int TypeIn = 3; //到货单入库
    public static final int AllotOk = 5; //配货完成
    public static final int PickOk = 4; //拣货完成

    //盘点时应该物料的状态范围 库存状态:0入库未上架-分配完标签后的状态 1在库正常 2停用 3标签损坏-1删除 4拣货 5配货 6发货
    public static final String PdStatic = "0,1,2,3";

    /**
     * 本地运行环境
     */
    public static final String DXQ_sandbox = "druid";
    /**
     * 请求前缀
     */
    public static final String DXQ_prefix = "/gdgy/api/isv";

    public static String active;

    @Value("${spring.profiles.active}")
    public void setActive(String active) {
        DxqConfig.active = active;
    }

    /**
     * 系统外网地址
     * @param myBaseUrl
     */
    @Value("${runtime.server.url}")
    public void setMyBaseUrl(String myBaseUrl) {
        DxqConfig.myBaseUrl = myBaseUrl;
    }

    //私有项目外网地址
    public static String myBaseUrl = "https://isv-dev.yonisv.com/yonbip-yisv-scc-gdgy01-dev-be";


    public static String appKey;

    public static String appSecret;

    public static String openApiUrlGateway;

    public static String tenantId;

    public static String appCode;

    @Value("${ucf.mdd.open-api.app-code}")
    public void setAppCode(String appCode) {
        DxqConfig.appCode = appCode;
    }

    @Value("${ucf.mdd.open-api.tenant-id}")
    public void setTenantId(String tenantId) {
        DxqConfig.tenantId = tenantId;
    }

    @Value("${ucf.mdd.open-api.app-key}")
    public void setAppKey(String appKey) {
        DxqConfig.appKey = appKey;
    }

    @Value("${ucf.mdd.open-api.app-secret}")
    public void setAppSecret(String appSecret) {
        DxqConfig.appSecret = appSecret;
    }

    //${domain.iuap-api-gateway}
    @Value("${openapi.apiprifx}")
    public void setOpenApiUrlGateway(String openApiUrlGateway) {
        DxqConfig.openApiUrlGateway = openApiUrlGateway;
    }

    public static String whiteListContain;

    @Value("${yms.session.whiteListContain}")
    public void setWhiteListContain(String whiteListContain){ DxqConfig.whiteListContain = whiteListContain; }

    /**
     * 默认加载配置
     */
    @PostConstruct
    public void init() {
        if (DxqConfig.DXQ_sandbox.equals(DxqConfig.active)) {
            new DxqConfig().setMyBaseUrl("http://localhost:8080");
        }
    }

    public static String domainKey;
    @Value("${bpmrest.appsource}")
    public void setDomainKey(String domainKey) {
        DxqConfig.domainKey = domainKey;
    }


    /**
     * 测试 ucf.mdd.suite.app-key
     * appKey:
     * de95441959594eed988de6a8cb8c71f2
     * appSecret:
     * e899d7e564c74e22a7584422fb0f1aca
     */
    public static String suiteKey;

    public static String suiteSecret;

    @Value("${ucf.mdd.open-api.isv-app-key}")
    public void setSuiteKey(String suiteKey) {
        this.suiteKey = suiteKey;
    }

    @Value("${ucf.mdd.open-api.isv-app-secret}")
    public void setSuiteSecret(String suiteSecret) {
        DxqConfig.suiteSecret = suiteSecret;
    }

}
